package com.hdax.dm.service;

import com.hdax.dm.entity.base.Image;
import com.hdax.dm.entity.item.Item;
import com.hdax.dm.feign.base.ImageFeign;
import com.hdax.dm.feign.item.ItemFeign;
import com.hdax.dm.vo.ItemDescVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemDescService {

    @Autowired
    private ItemFeign itemFeign;
    @Autowired
    private ImageFeign imageFeign;

    public ItemDescVo itemDesc(Long itemId){
        Item item = itemFeign.itemDesc(itemId);
        ItemDescVo itemDescVo = new ItemDescVo();
        Image image = imageFeign.image(item.getId(), 2L, 1L);
        itemDescVo.setImgUrl(image == null?"":image.getImgUrl());
        itemDescVo.setAdress(item.getCinema().getAddress());
        itemDescVo.setCinemaId(item.getCinema().getId());
        item.setCinemaId(item.getCinema().getId());
        BeanUtils.copyProperties(item.getCinema(),itemDescVo);
        BeanUtils.copyProperties(item,itemDescVo);
        return itemDescVo;
    }

}
